package com.gosophia.resource.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.bean.RequestResult;
import com.gosophia.resourcePermission.ws.ResourcePermissionWebService;
import com.gosophia.util.RequestResultUtil;

/**
 * 规则号是否存在
 * 
 * @author zhao_yanfang
 * 
 */
@Controller("ruleOrderAction")
@Scope("prototype")
public class RuleOrderAction extends BaseSupportAction {

	@Autowired
	private ResourcePermissionWebService resourcePermissionWebService;
	private boolean order;
	private String values;

	public String _execute() throws Exception {
		String[] str = values.split("_");
		long rid = Long.parseLong(str[1]);
		int oid = Integer.parseInt(str[0]);
		int srcOid = 0;
		if (str.length == 3) {
			srcOid = Integer.parseInt(str[2]);
		}
		if (srcOid == oid) {
			order = false;
		} else {
			try {
				order = resourcePermissionWebService.isRuleOrder(rid, oid);
			} catch (Exception e) {
				order = true;
			}
		}
//		this.requestResult = RequestResultUtil.getRequestResult();
		return SUCCESS;
	}

	public boolean isOrder() {
		return order;
	}

	public void setOrder(boolean order) {
		this.order = order;
	}

	public String getValues() {
		return values;
	}

	public void setValues(String values) {
		this.values = values;
	}

}
